/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            housekeepingFeeTypeInfo: {
                types: [],
                total: 0,
                records: 1,
                moreCondition: false,
                feeTypeCd: '',
                isShows: [],
                conditions: {
                    typeName: '',
                    isShow: '',
                    shopId: ''
                }
            }
        },
        _initMethod: function () {
            $that._listHousekeepingFeeTypes(DEFAULT_PAGE, DEFAULT_ROWS);
            vc.getDict('housekeeping_type', "is_show", function (_data) {
                $that.housekeepingFeeTypeInfo.isShows = _data;
            });
        },
        _initEvent: function () {
            vc.on('housekeepingFeeType', 'listHousekeepingFeeType', function (_param) {
                $that._listHousekeepingFeeTypes(DEFAULT_PAGE, DEFAULT_ROWS);
            });
            vc.on('pagination', 'page_event', function (_currentPage) {
                $that._listHousekeepingFeeTypes(_currentPage, DEFAULT_ROWS);
            });
        },
        methods: {
            _listHousekeepingFeeTypes: function (_page, _rows) {
                $that.housekeepingFeeTypeInfo.conditions.page = _page;
                $that.housekeepingFeeTypeInfo.conditions.row = _rows;
                $that.housekeepingFeeTypeInfo.conditions.shopId = vc.getCurrentCommunity().shopId;
                let param = {
                    params: $that.housekeepingFeeTypeInfo.conditions
                };
                param.params.typeName = param.params.typeName.trim();
                //发送get请求
                vc.http.apiGet('/housekeepingFeeType/queryHousekeepingFeeType',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        $that.housekeepingFeeTypeInfo.total = _json.total;
                        $that.housekeepingFeeTypeInfo.records = _json.records;
                        $that.housekeepingFeeTypeInfo.types = _json.data;
                        vc.emit('pagination', 'init', {
                            total: $that.housekeepingFeeTypeInfo.records,
                            dataCount: $that.housekeepingFeeTypeInfo.total,
                            currentPage: _page
                        });
                    }, function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            _openAddHousekeepingFeeTypeModal: function () {
                vc.emit('addHousekeepingFeeType', 'openAddHousekeepingFeeTypeModal', {});
            },
            _openEditHousekeepingFeeTypeModel: function (_housekeepingFeeType) {
                vc.emit('editHousekeepingFeeType', 'openEditHousekeepingFeeTypeModal', _housekeepingFeeType);
            },
            _openDeleteHousekeepingFeeTypeModel: function (_housekeepingFeeType) {
                vc.emit('deleteHousekeepingFeeType', 'openDeleteHousekeepingFeeTypeModal', _housekeepingFeeType);
            },
            //查询
            _queryHousekeepingFeeTypeMethod: function () {
                $that._listHousekeepingFeeTypes(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            //重置
            _resetHousekeepingFeeTypeMethod: function () {
                $that.housekeepingFeeTypeInfo.conditions.typeName = "";
                $that.housekeepingFeeTypeInfo.conditions.isShow = "";
                $that._listHousekeepingFeeTypes(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _moreCondition: function () {
                if ($that.housekeepingFeeTypeInfo.moreCondition) {
                    $that.housekeepingFeeTypeInfo.moreCondition = false;
                } else {
                    $that.housekeepingFeeTypeInfo.moreCondition = true;
                }
            }
        }
    });
})(window.vc);
